package com.huawei.appmarket.service.settings.card;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.settings.view.activity.ShowGameServiceAuthAppsActivity;
import java.lang.ref.WeakReference;
import o.AccountBussinessListener;
import o.ccp;
import o.cgz;
import o.der.d;
import o.der.f;
import o.Logger;
import o.doo;
import o.eod;
import o.eoj;
import o.evx;

public class SettingGameServiceCard extends BaseSettingCard {
    private a ˎ = new a(this.ॱ);
    private Context ॱ;

    static class a extends Handler {
        private WeakReference<Context> ॱ;

        a(Context context) {
            this.ॱ = new WeakReference(context);
        }

        public void handleMessage(Message message) {
            if (message.what != 4005) {
                return;
            }
            if (this.ॱ != null) {
                Context context = (Context) this.ॱ.get();
                if (context instanceof Activity) {
                    Activity activity = (Activity) context;
                    if (activity.isFinishing()) {
                        Logger.ˋ("SettingGameServiceCard", "activity is finishing");
                        return;
                    } else {
                        activity.startActivity(new Intent(activity, ShowGameServiceAuthAppsActivity.class));
                        return;
                    }
                }
                Logger.ˋ("SettingGameServiceCard", "context is not activity");
                return;
            }
            Logger.ˋ("SettingGameServiceCard", "weakReference == null");
        }
    }

    public SettingGameServiceCard(Context context) {
        super(context);
        this.ॱ = context;
    }

    public cgz ˏ(View view) {
        super.ˏ(view);
        ((TextView) view.findViewById(d.ʽʼ)).setText(f.ॱᐧ);
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        this.ˊˋ.setOnClickListener(new evx(this) {
            final /* synthetic */ SettingGameServiceCard ˎ;

            {
                this.ˎ = r1;
            }

            public void ˋ(View view) {
                if (!doo.ˊ(this.ˎ.ॱ.getApplicationContext())) {
                    Toast.makeText(this.ˎ.ॱ.getApplicationContext(), f.ʻʽ, 0).show();
                } else if (UserSession.getInstance().isLoginSuccessful()) {
                    this.ˎ.ॱ.startActivity(new Intent(this.ˎ.ॱ, ShowGameServiceAuthAppsActivity.class));
                } else {
                    eoj.ˋ().ˎ("SettingGameServiceCard", new AccountBussinessListener(this) {
                        final /* synthetic */ AnonymousClass5 ˊ;

                        {
                            this.ˊ = r1;
                        }

                        public void onAccountBusinessResult(ccp o_ccp) {
                            if (102 == o_ccp.ˎ && this.ˊ.ˎ.ˎ != null) {
                                this.ˊ.ˎ.ˎ.sendEmptyMessage(4005);
                            }
                            eoj.ˋ().ˊ("SettingGameServiceCard");
                        }
                    });
                    eod.ॱ(this.ˎ.ॱ);
                }
            }
        });
    }
}
